package com.qiwo.destop.content;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.qiwo.common.domain.ContentDO;
import com.qiwo.common.service.ContentService;
import com.qiwo.webshow.domain.DesignerDO;
import com.qiwo.webshow.domain.ImageDO;
import com.qiwo.webshow.service.DesignerService;
import com.qiwo.webshow.service.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Copyright
 *
 * @author chenwenchao
 * @date 2018/10/27 0027
 * Description:内容管理
 */
@Service
public class ContentInfo {

    @Autowired
    private ContentService contentService;
    @Autowired
    private DesignerService designerService;

    @Autowired
    private ImageService imageService;
    public ContentDO getContent(Integer id){
      Wrapper<ContentDO> contentDOWrapper=new EntityWrapper<>();
      contentDOWrapper.eq("type_id",id);
       return contentService.selectOne(contentDOWrapper);
    }
    public List<ContentDO> getContentList(Integer id){
        Wrapper<ContentDO> contentDOWrapper=new EntityWrapper<>();
        contentDOWrapper.orderBy("sort",true);
        contentDOWrapper.eq("type_id",id);
        return contentService.selectList(contentDOWrapper);
    }
    public List<DesignerDO> getDesigerList(){

        Wrapper<DesignerDO> designerDOWrapper=new EntityWrapper<>();
        designerDOWrapper.orderBy("sort",true);
       return designerService.selectList(designerDOWrapper);
    }
   public List<ImageDO> getImgsList(Integer contentId){
        Wrapper<ImageDO> wrapper=new EntityWrapper<>();
        wrapper.orderBy("sort",true);
        wrapper.eq("content_id",contentId);
      return imageService.selectList(wrapper);
   }

}
